home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 October / CHIP Turkiye Ekim 2000.iso / prog / naps / 04 / setup.exe / Gnucleus / ListCtrlEx.h < prev    next >
C/C++ Source or Header  |  2000-07-11  |  4KB  |  139 lines

  1. /********************************************************************************
  2.  
  3.     Gnucleus - A node application for the Gnutella network
  4.     Copyright (C) 2000 John Marshall
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; either version 2 of the License.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  
  19.     For support, questions, comments, etc...
  20.     E-Mail: 
  21.         swabby@c0re.net
  22.     
  23.     Address:
  24.         21 Cadogan Way
  25.         Nashua, NH, USA 03062
  26.  
  27. ********************************************************************************/
  28.  
  29.  
  30. #ifndef _CLISTCTRLEX_H_
  31. #define _CLISTCTRLEX_H_
  32.  
  33. #include "TitleTip.h"
  34. #include "HeaderCtrlEx.h"
  35.  
  36. #define LVNU_SELCHANGED 0x1000
  37.  
  38. class CListCtrlEx : public CListCtrl
  39. {
  40.  
  41.     DECLARE_DYNCREATE(CListCtrlEx)
  42.  
  43. // Construction
  44. public:
  45.     CListCtrlEx();
  46.     virtual ~CListCtrlEx();
  47.     void DragColumn(int source, int dest);
  48.     int GetColumnNumber( char *title );
  49.     int HitTestEx(CPoint &point, int *col) const;
  50.     
  51.     BOOL SetItemText( int nItem, int nSubItem, LPCTSTR lpszText );
  52.  
  53.     int GetNColumns();
  54.     CString GetColumnTitle( int n );
  55.  
  56. // Attributes
  57. protected:
  58.     CMyHeaderCtrl   m_headerctrl;
  59.     BOOL m_bFullRowSel;
  60.     BOOL m_bClientWidthSel;
  61.  
  62.     BOOL m_bDrawGrid;
  63.  
  64.     // For column sorting.
  65.     int nSortedCol; 
  66.     BOOL bSortAscending; 
  67.     CToolTipCtrl m_tooltip;
  68.  
  69.  
  70. public:
  71.     BOOL SetFullRowSel(BOOL bFillRowSel);
  72.     BOOL GetFullRowSel();
  73.     void SetDrawGrid( BOOL bDrawGrid );
  74.     BOOL GetDrawGrid();
  75.     CEdit* EditSubLabel( int nItem, int nCol );
  76.  
  77. // Overrides
  78. protected:
  79.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  80.  
  81.     // ClassWizard generated virtual function overrides
  82.     //{{AFX_VIRTUAL(CListCtrlEx)
  83.     public:
  84.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  85.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  86.     protected:
  87.     virtual void PreSubclassWindow();
  88.     //}}AFX_VIRTUAL
  89.  
  90. // Implementation
  91. public:
  92.     void EnableGenericSort(BOOL _use_generic = TRUE);
  93. #ifdef _DEBUG
  94.     virtual void Dump(CDumpContext& dc) const;
  95. #endif
  96.  
  97. protected:
  98.     void RepaintSelectedItems();
  99.  
  100. // Implementation - list view colors
  101.     COLORREF m_clrText;
  102.     COLORREF m_clrTextBk;
  103.     COLORREF m_clrBkgnd;
  104.     CTitleTip m_titletip;
  105.  
  106.     afx_msg LRESULT OnSetTextColor(WPARAM wParam, LPARAM lParam);
  107.     afx_msg LRESULT OnSetTextBkColor(WPARAM wParam, LPARAM lParam);
  108.     afx_msg LRESULT OnSetBkColor(WPARAM wParam, LPARAM lParam);
  109.  
  110.     bool HitTestRowCol(CPoint& point, int& iRow, int& iColumn);
  111.     CRect GetCellRect(int iRow, int iColumn)const;
  112.  
  113.     int  GetTrueColumnWidth(int nCurrentPosition)const;
  114.     CString GetTrueItemText(int row, int col)const;
  115.     void HideTitleTip();
  116.     void SendSelChangedNotification();
  117.     void ShowTitleTip(CPoint point);
  118.     void OnHeaderClicked(NMHDR* pNMHDR, LRESULT* pResult);
  119.     BOOL SortTextItems( int nCol, BOOL bAscending, int low = 0, int high = -1);
  120.  
  121. // Generated message map functions
  122. protected:
  123.     BOOL m_bUseGenericSort;
  124.     //{{AFX_MSG(CListCtrlEx)
  125.     afx_msg void OnPaint();
  126.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  127.     afx_msg void OnKillFocus(CWnd* pNewWnd);
  128.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  129.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  130.     afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  131.     afx_msg void OnDestroy();
  132.     afx_msg void OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult);
  133.     //}}AFX_MSG
  134.     DECLARE_MESSAGE_MAP()
  135. };
  136.  
  137. /////////////////////////////////////////////////////////////////////////////
  138. #endif
  139.